import Mock from 'mockjs';

Mock.mock(RegExp('/common/page'), 'get', (req) => {
    const { pageSize, pageNumber } = req.body;
    return Mock.mock({
        statusCode: 200,
        message: '查询成功',
        data: {
            total: 200,
            pageSize,
            pageNumber,
            ['list|' + pageNumber]: [
                {
                    id: '@id',
                    name: '@cname',
                }
            ]
        }
    })
});

Mock.mock(RegExp('/common/list'), 'get', () => {
    return Mock.mock({
        statusCode: 200,
        message: '查询成功',
        'data|20': [
            {
                id: '@id',
                name: '@cname',
            }
        ]
    })
});

Mock.mock(RegExp('/common/info'), 'get', () => {
    return {
        statusCode: 200,
        message: '查询成功',
        data: {
            id: '@id',
            name: '@cname'
        }
    }
});

Mock.mock(RegExp('/common/add'), 'post', () => {
    return {
        statusCode: 200,
        message: '新增成功',
        data: {}
    }
});

Mock.mock(RegExp('/common/add'), 'post', () => {
    return {
        statusCode: 200,
        message: '保存成功',
        data: {}
    }
});

Mock.mock(RegExp('/common/update'), 'post', () => {
    return {
        statusCode: 200,
        message: '更新成功',
        data: {}
    }
});

Mock.mock(RegExp('/common/delete'), 'post', () => {
    return {
        statusCode: 200,
        message: '删除成功',
        data: {}
    }
});
